Forecast date picker (historical browse / season replay)#1126
Closed
busbyk wants to merge 2 commits into
Closed
Conversation
Adds a danger-colored calendar date picker to the native single-zone forecast page so readers can browse any past forecast/statement for the zone. Default (no date) shows the current product; picking a date renders that historical product at a shareable, server-rendered dated URL (/forecasts/avalanche/[zone]/[date]). Implements issue 09. Data layer - Product list schema + archiveDates: noon valid-date rule (center tz), dedupe same-date products to the latest publish, carry danger_rating. - fetchProductArchive narrows server-side via date_start/date_end (the params avy uses; type/zone_id are ignored), fetches uncached + trims to a small slice, then caches via unstable_cache (the full archive is ~13MB for NWAC, over Next's 2MB fetch-cache limit). - fetchProductById for the historical product (immutable, long cache); kept view-only, not issue 02's adapter. - GET /api/[center]/forecast-archive?zone&from&to for lazy month loading. Pages - New on-demand dated route [zone]/[date] (immutable ISR, noindex). - Extracted shared NativeForecastView; live + dated pages compose it. - Live page anchors the picker window on the current product's date (not today) so off-season the calendar opens populated on that month. Picker (ForecastDatePicker.client) - shadcn Calendar in a popover; days colored by danger_rating via the shared dangerColor scale, no-product days disabled, current/selected day outlined; calendar lazy-loads older months' colors on demand. - Days, prev/next arrows, and "Current forecast" are real Next <Link>s so the global nextjs-toploader handles navigation feedback (its bar only starts on anchor clicks, not router.push). Verified live at desktop + 375px; tsc/lint/test (541) pass.
ADR 017 records the native forecast-glossary design: a national shared GlossaryTerms collection, client-side marking fed by a cache-tagged /api/glossary endpoint (decoupled from the forecast page cache), no per-center gate, and a definition popover with a "Learn more" link. Adds the "Forecast Glossary" cluster (Glossary Term, Glossary tooltip) to DOMAIN_CONTEXT.md and indexes 017 (plus back-filled 015/016) in the decisions README. Re-acknowledges the CLAUDE.md->README drift binding. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
Preview deployment: https://forecast-date-picker.preview.avy-fx.org |
Collaborator
Author
|
Folded into #1129, which now targets native-product-pages and shows the full combined stack diff for single-PR review. Branch kept as a safety net. |
Draft
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a danger-colored calendar date picker to the native forecast page so readers can browse a zone's published forecast history ("season replay") and jump to any past forecast. Implements
.scratch/native-product-pages/issues/09-forecast-date-picker.md.Related Issues
.scratch/native-product-pages/issues/09-forecast-date-picker.md(this PR)Key Changes
forecasts/avalanche/[zone]/[date]/page.tsx(date=YYYY-MM-DD): on-demand server render,revalidate=2592000(~immutable),dynamicParams=true,robots noindex.NativeForecastViewextracted fromNativeForecastPage(warning optional — historical views pass null) so live + dated pages render identically.ForecastDatePicker.client.tsx: shadcnCalendar(react-day-picker v9) in a Popover, days background-colored bydanger_ratingviadangerScale.ts; lazy-loads older months on demand.GET /api/[center]/forecast-archive?zone&from&to→{ dates: [{ date, productId, productType, dangerRating }] }for lazy month color loading; the page never ships the full archive.services/nac/archiveDates.ts(noon valid-date rule in center tz, dedupe-by-date latest-wins) + unit tests.<Link>s so the app'snextjs-toploaderbar shows (it only triggers on anchor clicks, notrouter.push).How to test
pnpm dev, open a NWAC zone forecast (e.g.nwac.localhost:3000/forecasts/avalanche/west-slopes-north)./[zone]/[date]; "Current forecast" returns to the live page; the toploader bar shows on navigation.pnpm test(archiveDates unit tests), at 375px + desktop.Screenshots / Demo video
Verified live at 375px + desktop; calendar colors match the afp widget's April-2026 pattern. (Add a capture if helpful for review.)
Migration Explanation
None — all changes are read-path (NAC archive fetching + presentation). No Payload schema or DB migration.
danger_ratingwas added to the zod product-list schema (API response shape), not a collection.Future enhancements / Questions
native-product-pagesonce Native forecast page: reconcile from replace-widgets + initial polish #1121 merges.